package grafica.ventanas;

import java.awt.Button;
import java.awt.Dialog;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Label;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


public class Mensaje extends Dialog implements ActionListener {
	
	
    private static final long serialVersionUID = 1L;
	private Button ok;
    public boolean isOk = false;

    public Mensaje(Frame frame, String msg, boolean okcan){
        super(frame, "Aviso", true);
        add("Center",new Label(msg));
        addOKPanel(okcan);
        setAutoRequestFocus(true);
        setSize(250, 100);
        setLocationRelativeTo(null);
        setVisible(true);
    }
    
    Mensaje(Frame frame, String msg){
        this(frame, msg, false);
    }
        
    void createOKButton(Panel p) {
        p.add(ok = new Button("OK"));
        ok.addActionListener(this); 
    }
    
    void addOKPanel( boolean okcan ) {
        Panel p = new Panel();
        p.setLayout(new FlowLayout());
        createOKButton( p );
        add("South",p);
    }

    @Override
	public void actionPerformed(ActionEvent ae){
        if(ae.getSource() == ok) {
            isOk = true;
            setVisible(false);
        }
    }		

}
